package com.pp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pp.common.pojo.User;
import com.pp.mapper.UserMapper;
import com.pp.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {


    @Autowired
    private UserMapper userMapper;

    @Override
    public void updateUser(User user) {

        QueryWrapper<User> userQueryWrapper= new QueryWrapper<>();
        userQueryWrapper.eq("username",user.getUsername());
        userMapper.update(user,userQueryWrapper);
    }

    @Override
    public User getPassword(User user) {
        User user1 = userMapper.selectOne(new QueryWrapper<User>().eq("username",user.getUsername()));
        return user1;
    }

    @Override
    public User selectUser(Integer id) {
        User user = userMapper.selectById(id);
        return user;
    }

    @Override
    public User selectByName(String username) {
        User user = userMapper.selectOne(new QueryWrapper<User>().eq("username", username));
        return user;
    }

}
